home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 201-225 / disk_218 / mandel / src / menu.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  9KB  |  335 lines

  1. /*
  2.  * M A N D E L B R O T      C O N S T R U C T I O N   S E T
  3.  *
  4.  * (C) Copyright 1989 by Olaf Seibert.
  5.  * Mandel may be freely distributed. See file 'doc/Notice' for details.
  6.  *
  7.  * Menu definitions.
  8.  */
  9.  
  10. #include <exec/types.h>
  11. #include <intuition/intuition.h>
  12.  
  13. #define MENUFRONTPEN 2
  14.  
  15. /*-
  16.  * (C)             project     options         draw        batch
  17.  * ----------------------------------------------------------------
  18.  * About Mandel... new *       colors *        function    file...
  19.  *           open... /O  resolution *    iplot       wait
  20.  *           save    /S  parameters      eplot       continue
  21.  *           save as...  priority *           abort
  22.  *           stop
  23.  *           quit    /Q
  24.  *
  25.  * new              colors      resolution     priority
  26.  * -------------------------------------------------------------
  27.  * absolute pos'n /A  select      normal     /1  normal /0
  28.  * enlarge      /E  modulo      1/2         /2  low    /-
  29.  * reduce      /R  ranges      1/3         /3
  30.  * shift      /T  palette /P  1/4         /4
  31.  * zoom in      /<          fill in    /F
  32.  * zoom out      />          hi-res     /H
  33.  *                  interlace  /I
  34.  *                  borderless /B
  35.  *                  halfbrite  //
  36.  *
  37.  * functions       iplot    eplot
  38.  * -------------------------------------------------------------------
  39.  * z^2-c       None     Depth
  40.  * z*c*(1-z)       Z        Z
  41.  * z^3+z*(c-1)-c
  42.  * i:user
  43.  * i:z^2-c
  44.  */
  45.  
  46. /*
  47.  * Define some handy shortcuts.
  48.  */
  49.  
  50. #define ITEXT(left,text) \
  51.     {  MENUFRONTPEN,AUTOBACKPEN,JAM1,left,1,NULL, (UBYTE*)text, NULL  }
  52.  
  53. #define ITEM(num,top,next,text,flags,mutex,cmd) \
  54.         SITEM(num,top,next,text,flags,mutex,cmd,NULL)
  55.  
  56. #define SITEM(num,top,next,text,flags,mutex,cmd,sub) \
  57.    {next,MLEFT,top,MWIDTH,10,flags,mutex,(APTR)&text[num],NULL,cmd,sub}
  58.  
  59. #define Ax    COMMSEQ
  60. #define Vx    CHECKIT
  61. #define VV    CHECKIT | CHECKED
  62. #define TG    MENUTOGGLE
  63. #define EN    ITEMENABLED
  64.  
  65. #define DEFMLEFT    40
  66.  
  67. /*
  68.  * First the menu texts.
  69.  */
  70.  
  71. struct IntuiText c_it[] = {
  72.     ITEXT(1, "About Mandel..."),
  73. };
  74.  
  75. struct IntuiText project_it[] = {
  76.     ITEXT(1, "New        \xBB"),    /* 0xBB is the >> character */
  77.     ITEXT(1, "Open..."),
  78.     ITEXT(1, "Save"),
  79.     ITEXT(1, "Save As..."),
  80.     ITEXT(1, "Stop"),
  81.     ITEXT(1, "Quit..."),
  82. };
  83.  
  84. struct IntuiText opts_it[] = {
  85.     ITEXT(1, "Colors     \xBB"),
  86.     ITEXT(1, "Resolution \xBB"),
  87.     ITEXT(1, "Parameters"),
  88.     ITEXT(1, "Priority   \xBB"),
  89. };
  90.  
  91. struct IntuiText draw_it[] = {
  92.     ITEXT(1, "Func  \xBB"),
  93.     ITEXT(1, "IPlot \xBB"),
  94.     ITEXT(1, "EPlot \xBB"),
  95. };
  96.  
  97. struct IntuiText batch_it[] = {
  98.     ITEXT(1, "File..."),
  99.     ITEXT(1, "Wait"),
  100.     ITEXT(1, "Continue"),
  101.     ITEXT(1, "Abort"),
  102. };
  103.  
  104. struct IntuiText new_it[] = {
  105.     ITEXT(1, "Absolute"),
  106.     ITEXT(1, "Enlarge"),
  107.     ITEXT(1, "Reduce"),
  108.     ITEXT(1, "Shift"),
  109.     ITEXT(1, "Zoom In"),
  110.     ITEXT(1, "Zoom Out"),
  111. };
  112.  
  113. struct IntuiText color_it[] = {
  114.     ITEXT(CHECKWIDTH, "Select"),
  115.     ITEXT(CHECKWIDTH, "Modulo"),
  116.     ITEXT(CHECKWIDTH, "Ranges"),
  117.     ITEXT(CHECKWIDTH, "Palette"),
  118. };
  119.  
  120. struct IntuiText pri_it[] = {
  121.     ITEXT(CHECKWIDTH, "Normal"),
  122.     ITEXT(CHECKWIDTH, "Low"),
  123. };
  124.  
  125. struct IntuiText res_it[] = {
  126.     ITEXT(CHECKWIDTH, "Normal"),
  127.     ITEXT(CHECKWIDTH, "1/2"),
  128.     ITEXT(CHECKWIDTH, "1/3"),
  129.     ITEXT(CHECKWIDTH, "1/4"),
  130.     ITEXT(CHECKWIDTH, "Fill In"),
  131.     ITEXT(CHECKWIDTH, "Hires"),
  132.     ITEXT(CHECKWIDTH, "Interlace"),
  133.     ITEXT(CHECKWIDTH, "BorderLess"),
  134.     ITEXT(CHECKWIDTH, "HalfBrite"),
  135. };
  136.  
  137. struct IntuiText fun_it[] = {
  138.     ITEXT(CHECKWIDTH, "Z^2-C"),
  139.     ITEXT(CHECKWIDTH, "Z*C*(1-Z)"),
  140.     ITEXT(CHECKWIDTH, "Z^3+Z*(C-1)-C"),
  141.     ITEXT(CHECKWIDTH, "iplot: User"),
  142.     ITEXT(CHECKWIDTH, "iplot: Z^2-C"),
  143. };
  144.  
  145. struct IntuiText plot_it[] = {
  146.     ITEXT(CHECKWIDTH, "None"),
  147.     ITEXT(CHECKWIDTH, "Depth"),
  148.     ITEXT(CHECKWIDTH, "Z"),
  149. };
  150.  
  151.  
  152. #define FLAGS    ITEMTEXT | ITEMENABLED | HIGHBOX
  153.  
  154. /*
  155.  *  New submenu
  156.  */
  157.  
  158. #define MLEFT    DEFMLEFT
  159. #define MWIDTH    8*8+2+COMMWIDTH+8   /* Funny we need 2 more pixels */
  160.  
  161. struct MenuItem new_mi[] = {
  162.     ITEM(0,05,&new_mi[1],new_it,FLAGS|Ax,0,'A'), /* absolute */
  163.     ITEM(1,15,&new_mi[2],new_it,FLAGS|Ax,0,'E'), /* enlarge */
  164.     ITEM(2,25,&new_mi[3],new_it,FLAGS|Ax,0,'R'), /* reduce */
  165.     ITEM(3,35,&new_mi[4],new_it,FLAGS|Ax,0,'T'), /* shift */
  166.     ITEM(4,45,&new_mi[5],new_it,FLAGS|Ax,0,'<'), /* Zoom In */
  167.     ITEM(5,55,NULL,      new_it,FLAGS|Ax,0,'>'), /* Zoom Out */
  168. };
  169.  
  170. /*
  171.  *  Colors submenu
  172.  */
  173.  
  174. #undef    MWIDTH
  175. #define MWIDTH    CHECKWIDTH+7*8+COMMWIDTH+8
  176.  
  177. struct MenuItem color_mi[] = {
  178.     ITEM(0,05,&color_mi[1],color_it,FLAGS|Vx,1<<1|1<<2,0), /* select */
  179.     ITEM(1,15,&color_mi[2],color_it,FLAGS|VV,1<<0|1<<2,0), /* modulo */
  180.     ITEM(2,25,&color_mi[3],color_it,FLAGS|Vx,1<<0|1<<1,0), /* ranges */
  181.     ITEM(3,35,NULL        ,color_it,FLAGS|Ax,0,      'P'), /* palette */
  182. };
  183.  
  184. #undef    MWIDTH
  185. #define MWIDTH CHECKWIDTH+10*8+COMMWIDTH+8
  186.  
  187. struct MenuItem res_mi[] = {
  188.     ITEM(0,05,&res_mi[1],res_it,FLAGS|Ax|VV,1<<1|1<<2|1<<3,'1'), /* normal */
  189.     ITEM(1,15,&res_mi[2],res_it,FLAGS|Ax|Vx,1<<0|1<<2|1<<3,'2'), /* 1/2 */
  190.     ITEM(2,25,&res_mi[3],res_it,FLAGS|Ax|Vx,1<<0|1<<1|1<<3,'3'), /* 1/3 */
  191.     ITEM(3,35,&res_mi[4],res_it,FLAGS|Ax|Vx,1<<0|1<<1|1<<2,'4'), /* 1/4 */
  192.     ITEM(4,45,&res_mi[5],res_it,FLAGS|Ax   ,0             ,'F'), /* fill in */
  193.  
  194.     ITEM(5,60,&res_mi[6],res_it,FLAGS|Ax|Vx|TG,1<<8,'H'),   /* hi-res */
  195.     ITEM(6,70,&res_mi[7],res_it,FLAGS|Ax|Vx|TG,0   ,'I'),   /* interlace */
  196.     ITEM(7,80,&res_mi[8],res_it,FLAGS|Ax|Vx|TG,0   ,'B'),   /* borderless */
  197.     ITEM(8,90,NULL      ,res_it,FLAGS|Ax|Vx|TG,1<<4,'/'),   /* extra halfbrite */
  198. };
  199.  
  200. #undef    MWIDTH
  201. #define MWIDTH CHECKWIDTH+6*8+COMMWIDTH+8
  202.  
  203. struct MenuItem pri_mi[] = {
  204.     ITEM(0,05,&pri_mi[1],pri_it,FLAGS|Ax|VV,1<<1,'0'), /* normal */
  205.     ITEM(1,15,NULL      ,pri_it,FLAGS|Ax|Vx,1<<0,'-'), /* low */
  206. };
  207.  
  208. /*
  209.  *  Functions submenu:
  210.  */
  211.  
  212. #undef    MWIDTH
  213. #define MWIDTH    CHECKWIDTH+104
  214. #undef    MLEFT
  215. #define MLEFT    DEFMLEFT - 8
  216.  
  217. struct MenuItem fun_mi[] = {
  218.     ITEM(0,05,&fun_mi[1],fun_it,FLAGS|VV,0x1F- 1,0), /* Z^2 - C */
  219.     ITEM(1,15,&fun_mi[2],fun_it,FLAGS|Vx,0x1F- 2,0), /* z*c*(1-z) */
  220.     ITEM(2,25,&fun_mi[3],fun_it,FLAGS|Vx,0x1F- 4,0), /* z^3+z*(c-1)-c */
  221.     ITEM(3,35,&fun_mi[4],fun_it,FLAGS|Vx,0x1F- 8,0), /* i: User */
  222.     ITEM(4,45,NULL      ,fun_it,FLAGS|Vx,0x1F-16,0), /* i: Z^2 - C */
  223. };
  224.  
  225. /*
  226.  *  iplot submenu
  227.  */
  228.  
  229. #undef    MWIDTH
  230. #define MWIDTH    CHECKWIDTH + (5*8)
  231. #undef    MLEFT
  232. #define MLEFT    DEFMLEFT
  233.  
  234. struct MenuItem iplot_mi[] = {
  235.     ITEM(0,05,&iplot_mi[1],  plot_it,  FLAGS|VV,1<<1,0), /* None */
  236.     ITEM(1,15,NULL        ,(plot_it+1),FLAGS|Vx,1<<0,0), /* Z */
  237. };
  238.  
  239. /*
  240.  *  eplot submenu
  241.  */
  242.  
  243. struct MenuItem eplot_mi[] = {
  244.     ITEM(0,05,&eplot_mi[1],(plot_it+1),FLAGS|VV,1<<1,0), /* Depth */
  245.     ITEM(1,15,NULL        ,(plot_it+1),FLAGS|Vx,1<<0,0), /* Z */
  246. };
  247.  
  248. /*
  249.  *  (C) menu
  250.  */
  251.  
  252. #undef    MLEFT
  253. #define MLEFT    0
  254. #undef    MWIDTH
  255. #define MWIDTH    15*8
  256.  
  257. struct MenuItem c_mi[] = {
  258.     ITEM(0,00,NULL,c_it,FLAGS,0,0), /* About Mandel... */
  259. };
  260.  
  261. /*
  262.  *  Project menu
  263.  */
  264.  
  265. #undef    MWIDTH
  266. #define MWIDTH    9*8+COMMWIDTH
  267.  
  268. struct MenuItem project_mi[] = {
  269.     SITEM(0,00,&project_mi[1],project_it,FLAGS   ,0,0,new_mi), /* new */
  270.      ITEM(1,10,&project_mi[2],project_it,FLAGS|Ax,0,'O'     ), /* open... */
  271.      ITEM(2,20,&project_mi[3],project_it,FLAGS|Ax,0,'S'     ), /* save */
  272.      ITEM(3,30,&project_mi[4],project_it,FLAGS   ,0,0       ), /* save as... */
  273.      ITEM(4,45,&project_mi[5],project_it,FLAGS   ,0,0       ), /* stop */
  274.      ITEM(5,55,NULL          ,project_it,FLAGS|Ax,0,'Q'     ), /* quit */
  275. };
  276.  
  277. /*
  278.  *  Options menu
  279.  */
  280.  
  281. #undef    MWIDTH
  282. #define MWIDTH 12*8+2
  283.  
  284. struct MenuItem opt_mi[] = {
  285.     SITEM(0,00,&opt_mi[1],opts_it,FLAGS,0,0,color_mi), /* colors */
  286.     SITEM(1,10,&opt_mi[2],opts_it,FLAGS,0,0,res_mi  ), /* resolution */
  287.      ITEM(2,20,&opt_mi[3],opts_it,FLAGS,0,0         ), /* parameters */
  288.     SITEM(3,30,NULL      ,opts_it,FLAGS,0,0,pri_mi  ), /* priority */
  289. };
  290.  
  291.  
  292. /*
  293.  *  Draw Menu
  294.  */
  295.  
  296. #undef    MWIDTH
  297. #define MWIDTH    (7*8)
  298. #undef    MLEFT
  299. #define MLEFT    -MWIDTH+40
  300.  
  301. struct MenuItem draw_mi[] = {
  302.     SITEM(0,00,&draw_mi[1],draw_it,FLAGS,0,0,fun_mi  ), /* func */
  303.     SITEM(1,10,&draw_mi[2],draw_it,FLAGS,0,0,iplot_mi), /* iplot */
  304.     SITEM(2,20,NULL       ,draw_it,FLAGS,0,0,eplot_mi), /* eplot */
  305. };
  306.  
  307.  
  308. /*
  309.  *  Batch Menu
  310.  */
  311.  
  312. #undef    MWIDTH
  313. #define MWIDTH    (8*8)
  314. #undef    MLEFT
  315. #define MLEFT    -MWIDTH+43
  316.  
  317. struct MenuItem batch_mi[] = {
  318.     ITEM(0,00,&batch_mi[1],batch_it,FLAGS,     0,0), /* file */
  319.     ITEM(1,10,&batch_mi[2],batch_it,(FLAGS)-EN,0,0), /* wait */
  320.     ITEM(2,20,&batch_mi[3],batch_it,(FLAGS)-EN,0,0), /* continue */
  321.     ITEM(3,30,NULL        ,batch_it,(FLAGS)-EN,0,0), /* abort */
  322. };
  323.  
  324. /*
  325.  *  Main MenuStrip structure
  326.  */
  327.  
  328. struct Menu MandelMenu[] = {
  329.     { &MandelMenu[1],    2,0,21,10, MENUENABLED, " \xA9",    c_mi       },
  330.     { &MandelMenu[2],  30,0,59,10, MENUENABLED, "Project",  project_mi },
  331.     { &MandelMenu[3], 100,0,59,10, MENUENABLED, "Options",  opt_mi     },
  332.     { &MandelMenu[4], 170,0,37,10, MENUENABLED, "Draw",     draw_mi    },
  333.     { NULL,          220,0,43,10, MENUENABLED, "Batch",    batch_mi   },
  334. };
  335.